package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WcCarInfo;
import com.ruoyi.system.service.IWcCarInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车型信息Controller
 * 
 * @author ruoyi
 * @date 2020-01-20
 */
@Controller
@RequestMapping("/system/wccarinfo")
public class WcCarInfoController extends BaseController
{
    private String prefix = "system/wccarinfo";

    @Autowired
    private IWcCarInfoService wcCarInfoService;

    @RequiresPermissions("system:wccarinfo:view")
    @GetMapping()
    public String wccarinfo()
    {
        return prefix + "/wccarinfo";
    }

    /**
     * 查询车型信息列表
     */
    @RequiresPermissions("system:wccarinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestBody WcCarInfo wcCarInfo)
    {
        startPage();
        List<WcCarInfo> list = wcCarInfoService.selectWcCarInfoList(wcCarInfo);
        return getDataTable(list);
    }

    /**
     * 导出车型信息列表
     */
    @RequiresPermissions("system:wccarinfo:export")
    @Log(title = "车型信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WcCarInfo wcCarInfo)
    {
        List<WcCarInfo> list = wcCarInfoService.selectWcCarInfoList(wcCarInfo);
        ExcelUtil<WcCarInfo> util = new ExcelUtil<WcCarInfo>(WcCarInfo.class);
        return util.exportExcel(list, "wccarinfo");
    }

    /**
     * 新增车型信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存车型信息
     */
    @RequiresPermissions("system:wccarinfo:add")
    @Log(title = "车型信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WcCarInfo wcCarInfo)
    {
        return toAjax(wcCarInfoService.insertWcCarInfo(wcCarInfo));
    }

    /**
     * 修改车型信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WcCarInfo wcCarInfo = wcCarInfoService.selectWcCarInfoById(id);
        mmap.put("wcCarInfo", wcCarInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存车型信息
     */
    @RequiresPermissions("system:wccarinfo:edit")
    @Log(title = "车型信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WcCarInfo wcCarInfo)
    {
        return toAjax(wcCarInfoService.updateWcCarInfo(wcCarInfo));
    }

    /**
     * 删除车型信息
     */
    @RequiresPermissions("system:wccarinfo:remove")
    @Log(title = "车型信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wcCarInfoService.deleteWcCarInfoByIds(ids));
    }
}
